﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sales
{
    public class Granted : IOrderState
    {
        private SalesOrder salesOrder;

        public Granted(SalesOrder salesOrder)
        {
            // TODO: Complete member initialization
            this.salesOrder = salesOrder;
        }
        public void AddOrderLine()
        {
            this.salesOrder._AddOrderLine();
        }

        public void Register()
        {
            throw new ChangeStateException("Already registered!");
        }

        public void Grant()
        {
            throw new ChangeStateException("Already granted!");
        }

        public void Ship()
        {
            this.salesOrder._Ship();
            this.salesOrder.currentState = new Shipped(this.salesOrder);
        }

        public void Invoice()
        {
            throw new ChangeStateException("Not shipped yet!");
        }

        public void Cancel()
        {
            this.salesOrder._Cancel();
            this.salesOrder.currentState = new Canceled(this.salesOrder);
        }
    }
}
